#ifndef _SPRITE_SYSTEM_H_
#define _SPRITE_SYSTEM_H_

#include "System.h"
#include "SpriteComponent.h"

#include "Singleton.h"
#include "Window.h"

#include <vector>

class SpriteSystem : public fe::System, public Singleton<SpriteSystem>
{
public:
    SpriteSystem();
    ~SpriteSystem();

    inline void execute()
    {
        for(unsigned int i = 0; i < m_component.size(); i++)
        {
            if(!m_component[i])  // removes if not valid
            {
                m_component.erase(m_component.begin() + i);
                i--;
                continue;
            }
            m_component[i]->render(*m_window);
        }
    }

    void addComponent(Sprite* sc) { m_component.push_back(sc); }

    Sprite* getComponent(int index) { return m_component[index]; }

    void setWindow(fe::Window* window) { m_window = window; }


private:
    fe::Window *m_window;
    std::vector<Sprite*> m_component;
};

#endif
